package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    Page<DishVO> getPage(DishPageQueryDTO dto);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    @Select("select * from dish where id = #{dishId}")
    Dish selectById(Long dishId);

    void batchDelete(Long[] ids);

    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> getByCategory(Long categoryId);


    @Select("select image,description from dish where id = #{dishId}")
    Dish getDishImageAndDescription(Long dishId);

    @Select("select count(id) from dish where status = #{status}")
    Integer getDishesOverview(Integer status);
}
